<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>登录</title>
    <script th:src="@{/static/js/jquery.min.js}"></script>
</head>

<script type="text/javascript">
    $(function(){
        $("#submit").click(function () {
            login();
        });
    });

    function login() {
        var data = {};
        data.username = $("#username").val();
        data.password = $("#password").val();
        console.info("data",data);
        /*$.post("http://localhost/login", data, function(datas,status) {
        });*/
        //window.location.href="/login?username="+data.username+"&password="+data.password;
        $.ajax({
            type: "POST",
            url: "/login",
            data: data,
            dataType: "json",
            success: function (json) {
                window.location.href = "/";
                /*console.info(json);
                if (json  == "ok") {
                    window.location.href = "/index";
                }else{
                    alert("登陆失败");
                }*/
            }
        });
    }
</script>
<body>
    <div><span style="font-size: 16px">用户名</span><input type="text" id="username"/></div>
    <div><span style="font-size: 16px;text-align: right">密码</span><input type="text" id="password"/></div>
    <div><span th:text="${msg}">info:</span><div>
    <div><button id="submit" type="button">登录</button></div>
</body>
</html>
